package com.springboot.husha.controller.app;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.springboot.husha.entity.Fenggedashan;
import com.springboot.husha.entity.Lunbotu;
import com.springboot.husha.qpage.QPage;
import com.springboot.husha.service.IFenggedashanService;
import com.springboot.husha.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 风格大赏 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-02-28
 */
@Controller
@RequestMapping("/api/front/fenggedashan")
public class AppFenggedashanController {


    /**
     * 路由地址
     */
    public String prefix = "/view/front/fenggedashan";

    /**
     * 业务层
     */
    @Autowired
    private IFenggedashanService service;

    /**
     * 进入管理页面
     * @return
     */
    @RequestMapping("/index")
    public String index(){
        return prefix+"/index";
    }


    /**
     * 获取所有的列表
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Result getList(Integer num, Fenggedashan obj) {
        QueryWrapper<Fenggedashan> queryWrapper=new QueryWrapper<>();
        if(num!=null&&num>0){
            queryWrapper.last(" limit "+num);
        }
        List<Fenggedashan> fenggedashanList=this.service.list(queryWrapper);
        return Result.reOk("查询成功",fenggedashanList);
    }

    /**
     * 进入编辑页面
     * @return
     */
    @RequestMapping("/edit")
    public String edit(){
        return prefix+"/edit";
    }

    /**
     * 根据ID获取信息
     * @param id
     * @return
     */
    @RequestMapping("/getById")
    @ResponseBody
    public Result getById(Integer id) {
        return Result.reOk("查询成功",this.service.getById(id));
    }


}
